package com.iot.service.config;

import com.google.gson.Gson;
import com.iot.service.mqtt.service.acl.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.InputStream;
import java.net.http.HttpClient;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: hszhou
 * @Date: 2025/4/22 15:39
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
@Configuration
@Slf4j
public class WebConfig {

    @Bean
    public Gson gson() {
        return new Gson();
    }


    @Bean
    public HttpClient httpClient(){
        return HttpClient.newHttpClient();
    }



    @Bean
    public AclValidator aclValidator(){

        InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("acl.conf");
        System.out.println(resourceAsStream);
//        List<AclRule> rules = AclConfigParser.parse("acl.conf");
        //FileAclValidator fileAclValidator = new FileAclValidator(rules);
        List<AclValidator> validators = new ArrayList<>();
        //validators.add(fileAclValidator);
        return new CompositeAclValidator(validators);
    }

}
